﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Account.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the Account type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Model
{
    using System;
    using System.ComponentModel;

    /// <summary>
    /// Defines the <seealso cref="Account"/>  type.
    /// </summary>
    public class Account : ModelBase, IDataErrorInfo
    {
        #region Member Variables

        /// <summary>
        /// Member variable _accountId
        /// </summary>
        private int _accountId;

        /// <summary>
        /// Member variable _name
        /// </summary>
        private string _name;

        /// <summary>
        /// Member variable _accountNumber
        /// </summary>
        private string _accountNumber;

        /// <summary>
        /// Member variable _accountType
        /// </summary>
        private int _accountType;

        /// <summary>
        /// Member variable _initialBalanceDate
        /// </summary>
        private DateTime _initialBalanceDate;

        /// <summary>
        /// Member variable _initialBalance
        /// </summary>
        private decimal _initialBalance;

        /// <summary>
        /// Member variable _userId
        /// </summary>
        private int _userId;

        #endregion Member Variables

        /// <summary>
        /// Gets or sets the account id.
        /// </summary>
        /// <value>
        /// The account id.
        /// </value>
        public int AccountId
        {
            get
            {
                return _accountId;
            }

            set
            {
                if (_accountId != value)
                {
                    _accountId = value;
                    RaisePropertyChangedEvent("AccountId");
                }
            }
        }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        /// <value>
        /// The title.
        /// </value>
        public string Name
        {
            get
            {
                return _name;
            }

            set
            {
                if (_name != value)
                {
                    _name = value;
                    RaisePropertyChangedEvent("Name");
                }
            }
        }

        /// <summary>
        /// Gets or sets the name
        /// </summary>
        /// <value>
        /// The title.
        /// </value>
        public string AccountNumber
        {
            get
            {
                return _accountNumber;
            }

            set
            {
                if (_accountNumber != value)
                {
                    _accountNumber = value;
                    RaisePropertyChangedEvent("AccountNumber");
                }
            }
        }

        /// <summary>
        /// Gets or sets the type of the account.
        /// </summary>
        /// <value>
        /// The type of the account.
        /// </value>
        public int AccountType
        {
            get
            {
                return _accountType;
            }

            set
            {
                if (_accountType != value)
                {
                    _accountType = value;
                    RaisePropertyChangedEvent("AccountType");
                }
            }
        }

        /// <summary>
        /// Gets or sets the initial balance date.
        /// </summary>
        /// <value>
        /// The initial balance date.
        /// </value>
        public DateTime InitialBalanceDate
        {
            get
            {
                return _initialBalanceDate;
            }

            set
            {
                if (_initialBalanceDate != value)
                {
                    _initialBalanceDate = value;
                    RaisePropertyChangedEvent("AccountType");
                }
            }
        }

        /// <summary>
        /// Gets or sets the initial balance.
        /// </summary>
        /// <value>
        /// The initial balance.
        /// </value>
        public decimal InitialBalance
        {
            get
            {
                return _initialBalance;
            }

            set
            {
                if (_initialBalance != value)
                {
                    _initialBalance = value;
                    RaisePropertyChangedEvent("AccountType");
                }
            }
        }

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>
        /// The user id.
        /// </value>
        public int UserId
        {
            get
            {
                return _userId;
            }

            set
            {
                if (_userId != value)
                {
                    _userId = value;
                    RaisePropertyChangedEvent("AccountType");
                }
            }
        }

        #region Implementation of IDataErrorInfo

        /// <summary>
        /// Gets an error message indicating what is wrong with this object.
        /// </summary>
        /// <returns>
        /// An error message indicating what is wrong with this object. The default is an empty string ("").
        /// </returns>
        public string Error
        {
            get
            {
                return null;
            }
        }

        /// <summary>
        /// Gets the error message for the property with the given name.
        /// </summary>
        /// <returns>
        /// The error message for the property. The default is an empty string ("").
        /// </returns>
        /// <param name="columnName">The name of the property whose error message to get. </param>
        public string this[string columnName]
        {
            get
            {
                string result = null;

                if (columnName == "Name")
                {
                    if (string.IsNullOrWhiteSpace(Name))
                    {
                        result = "Name is required";
                    }
                }

                return result;
            }
        }

        #endregion Implementation of IDataErrorInfo
    }
}